home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / mtgdi / mtgdi.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.2 KB  |  129 lines

  1. // mtgdi.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1999 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "mtgdi.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "mtgdidoc.h"
  18. #include "mtgdivw.h"
  19. #include "threads.h"
  20.  
  21.  
  22.  
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char BASED_CODE THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. BEGIN_MESSAGE_MAP(CThreadApp, CWinApp)
  29.     //{{AFX_MSG_MAP(CThreadApp)
  30.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  31.         // NOTE - the ClassWizard will add and remove mapping macros here.
  32.         //    DO NOT EDIT what you see in these blocks of generated code!
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37. END_MESSAGE_MAP()
  38.  
  39. CThreadApp theApp;
  40.  
  41. BOOL CThreadApp::InitInstance()
  42. {
  43.     // Initialize static members of CGDIThread
  44.     InitializeCriticalSection(&CGDIThread::m_csGDILock);
  45.  
  46.     // Register the application's document templates.  Document templates
  47.     //  serve as the connection between documents, frame windows and views.
  48.     CSingleDocTemplate* pDocTemplate;
  49.     pDocTemplate = new CSingleDocTemplate(
  50.         IDR_MAINFRAME,
  51.         RUNTIME_CLASS(CThreadDoc),
  52.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  53.         RUNTIME_CLASS(CThreadView));
  54.     AddDocTemplate(pDocTemplate);
  55.  
  56.     // create a new (empty) document
  57.     OnFileNew();
  58.  
  59.     return TRUE;
  60. }
  61.  
  62. int CThreadApp::ExitInstance() 
  63. {
  64.     DeleteCriticalSection(&CGDIThread::m_csGDILock);
  65.     CloseHandle(CGDIThread::m_hAnotherDead);
  66.     
  67.     return CWinApp::ExitInstance();
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CAboutDlg dialog used for App About
  72.  
  73. class CAboutDlg : public CDialog
  74. {
  75. public:
  76.     CAboutDlg();
  77.  
  78. // Dialog Data
  79.     //{{AFX_DATA(CAboutDlg)
  80.     enum { IDD = IDD_ABOUTBOX };
  81.     //}}AFX_DATA
  82.  
  83. // Implementation
  84. protected:
  85.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  86.     //{{AFX_MSG(CAboutDlg)
  87.     virtual BOOL OnInitDialog();
  88.     //}}AFX_MSG
  89.     DECLARE_MESSAGE_MAP()
  90. };
  91.  
  92. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  93. {
  94.     //{{AFX_DATA_INIT(CAboutDlg)
  95.     //}}AFX_DATA_INIT
  96. }
  97.  
  98. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  99. {
  100.     CDialog::DoDataExchange(pDX);
  101.     //{{AFX_DATA_MAP(CAboutDlg)
  102.     //}}AFX_DATA_MAP
  103. }
  104.  
  105. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  106.     //{{AFX_MSG_MAP(CAboutDlg)
  107.         // No message handlers
  108.     //}}AFX_MSG_MAP
  109. END_MESSAGE_MAP()
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CAboutDlg message handlers
  113.  
  114. BOOL CAboutDlg::OnInitDialog() 
  115. {
  116.     CDialog::OnInitDialog();
  117.     CenterWindow();    
  118.     return TRUE;  // return TRUE unless you set the focus to a control
  119.                   // EXCEPTION: OCX Property Pages should return FALSE
  120. }
  121.  
  122. // App command to run the dialog
  123. void CThreadApp::OnAppAbout()
  124. {
  125.     CAboutDlg about;
  126.     about.DoModal();
  127. }
  128.  
  129.